package com.example.design.shejimoshi.action.responsibility;

/**
 * 处理器类的抽象父类(该类本身就用到了模板模式)
 */
public abstract class AbstractHandler {
    private AbstractHandler nextAbstractHandler;

    public void setNextHandler(AbstractHandler abstractHandler){
        this.nextAbstractHandler = abstractHandler;
    }

    // 留给子类实现
    abstract void doFilter(UserDO userDO);

    // 模板
    public void filter(UserDO userDO){
        doFilter(userDO);

        if (nextAbstractHandler != null){
            nextAbstractHandler.filter(userDO);
        }
    }

}
